﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 草稿1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }
        OleDbDataAdapter oda = null;
        DataSet ds = null;
        

        private void button1_Click(object sender, EventArgs e)
        {
            string str = "provider=microsoft.jet.oledb.4.0;data source=E:/C#/考核六/k6.mdb";
            OleDbConnection oc = new OleDbConnection();
            oc.ConnectionString = str;
            string str1 = "select * from zym";
            oda = new OleDbDataAdapter(str1, oc);
            ds = new DataSet();
            oda.Fill(ds, "zym");
            dataGridView1.DataSource = ds.Tables["zym"];
            oc.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            OleDbCommandBuilder ob = new OleDbCommandBuilder(oda);
            if(ds.HasChanges())
            {
                oda.Update(ds, "zym");
                MessageBox.Show("数据更新成功！");
            }
        }
    }
}
